package com.ruoyi.merchantdata.enums;

import cn.hutool.core.util.ObjectUtil;
import lombok.Getter;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Getter
public enum StarTypeEnum {

    ZERO(0, "0星"),
    ONE(1, "1星"),
    TWO(2, "2星"),
    TWOPLUS(3, "2+星"),
    THREE(4, "3星"),
    FOUR(5, "4星"),
    FIVE(6, "5星"),
    MAJOR(7, "重要客户"),
    ;

    Integer value;
    String name;

    StarTypeEnum(Integer value, String name){
        this.value = value;
        this.name = name;
    }

    public static String getNameByValue(Integer value){
        for (StarTypeEnum item: values()){
            if (ObjectUtil.equal(item.getValue(), value)){
                return item.getName();
            }
        }
        return value+"";
    }

    public static List<Map<String, Object>> getMapList(){

        List<Map<String, Object>> resultList = new ArrayList<>();
        for (StarTypeEnum item: values()){
            Map<String, Object> map = new HashMap<>();
            map.put("name", item.getName());
            map.put("value", item.getValue());
            resultList.add(map);
        }
        return resultList;
    }

}
